<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>zfilter2</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="zawm.html" title="zawm" />
    <link rel="next" href="zir.html" title="zir" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">zfilter2</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="zawm.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="zir.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="zfilter2"></a>
      <div class="titlepage"></div>
      <a id="IndexZfilter2" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">zfilter2</span>
        </h2>
        <p>zfilter2 — 
      Performs filtering using a transposed form-II digital filter lattice with radial pole-shearing and angular pole-warping.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169805056"></a>
        <h2>Description</h2>
        <p>
      General purpose custom filter with time-varying pole control. The filter coefficients implement the following difference equation:
      </p>
        <div class="literallayout">
          <p><br />
(1)*y(n) = b0*x[n] + b1*x[n-1] +...+ bM*x[n-M] - a1*y[n-1] -...- aN*y[n-N]<br />
      </p>
        </div>
        <p>
    </p>
        <p>
      the system function for which is represented by:
      </p>
        <div class="literallayout">
          <p><br />
           B(Z)      b0 + b1*Z<sup>-1</sup>  + ... + bM*Z<sup>-M</sup><br />
  H(Z)  =  ----  =  --------------------------<br />
           A(Z)       1 + a1*Z<sup>-1</sup>  + ... + aN*Z<sup>-N</sup><br />
      </p>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169810384"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>zfilter2</strong></span> asig, kdamp, kfreq, iM, iN, ib0, ib1, ..., ibM, \
      ia1,ia2, ..., iaN</pre>
      </div>
      <div class="refsect1">
        <a id="idp169812656"></a>
        <h2>Initialization</h2>
        <p>
      At initialization the number of zeros and poles of the filter are specified along with the corresponding zero and pole coefficients. The coefficients must be obtained by an external filter-design application such as Matlab and specified directly or loaded into a table via <a class="link" href="GEN01.html" title="GEN01"><em class="citetitle">GEN01</em></a>. With <span class="emphasis"><em>zfilter2</em></span>, the roots of the characteristic polynomials are solved at initialization so that the pole-control operations can be implemented efficiently.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169815680"></a>
        <h2>Performance</h2>
        <p>
      The <a class="link" href="filter2.html" title="filter2"><em class="citetitle">filter2</em></a> opcodes perform filtering using a transposed form-II digital filter lattice with no time-varying control. <span class="emphasis"><em>zfilter2</em></span> uses the additional operations of radial pole-shearing and angular pole-warping in the Z plane.
    </p>
        <p>
      Pole shearing increases the magnitude of poles along radial lines in the Z-plane. This has the affect of altering filter ring times. The k-rate variable <span class="emphasis"><em>kdamp</em></span> is the damping parameter. Positive values (0.01 to 0.99) increase the ring-time of the filter (hi-Q), negative values (-0.01 to -0.99) decrease the ring-time of the filter, (lo-Q).
    </p>
        <p>
      Pole warping changes the frequency of poles by moving them along angular paths in the Z plane. This operation leaves the shape of the magnitude response unchanged but alters the frequencies by a constant factor (preserving 0 and p). The k-rate variable <span class="emphasis"><em>kfreq</em></span> determines the frequency warp factor. Positive values (0.01 to 0.99) increase frequencies toward p and negative values (-0.01 to -0.99) decrease frequencies toward 0.
    </p>
        <p>
      Since <span class="emphasis"><em>filter2</em></span> implements generalized recursive filters, it can be used to specify a large range of general DSP algorithms. For example, a digital waveguide can be implemented for musical instrument modeling using a pair of <a class="link" href="delayr.html" title="delayr"><em class="citetitle">delayr</em></a> and <a class="link" href="delayw.html" title="delayw"><em class="citetitle">delayw</em></a> opcodes in conjunction with the <span class="emphasis"><em>filter2</em></span> opcode.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169824368"></a>
        <h2>Examples</h2>
        <p>
      A controllable second-order IIR filter operating on an a-rate signal:
      </p>
        <div class="informalexample">
          <pre class="programlisting">
a1 <span class="opc">zfilter2</span> asig, kdamp, kfreq, 1, 2, 1, ia1, ia2 <span class="comment">;; controllable a-rate IIR filter</span></pre>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169828000"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="filter2.html" title="filter2"><em class="citetitle">filter2</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169830112"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Michael A. Casey</td>
          </tr>
          <tr>
            <td>M.I.T.</td>
          </tr>
          <tr>
            <td>Cambridge, Mass.</td>
          </tr>
          <tr>
            <td>1997</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Version 3.47</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="zawm.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="zir.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">zawm </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> zir</td>
        </tr>
      </table>
    </div>
  </body>
</html>
